import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

// 定义Person类
class Person {
    private String name;
    private int age;

    // 无参构造方法
    public Person() {}

    // 有参构造方法
    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    // Getter和Setter方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    // toString方法
    @Override
    public String toString() {
        return "Person [name=" + name + ", age=" + age + "]";
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        List<Person> list = new ArrayList<>();

        // 输入n表示对象个数
        int n = scanner.nextInt();
        scanner.nextLine(); // 消耗换行符

        // 循环输入n个Person对象
        for (int i = 0; i < n; i++) {
            String name = scanner.next();
            int age = scanner.nextInt();
            list.add(new Person(name, age));
        }

        // 输出列表中所有Person对象信息
        for (Person person : list) {
            System.out.println(person);
        }

        // 输入一个字符串表示姓名，进行查询
        String queryName = scanner.next();
        boolean found = false;
        for (Person person : list) {
            if (person.getName().equals(queryName)) {
                System.out.println(person);
                found = true;
                break;
            }
        }
        if (!found) {
            System.out.println("此人不存在");
        }

        scanner.close();
    }
}